package com.code.translate.enums;

import com.code.translate.function.TextTranslatePlugin;
import com.code.translate.manager.PluginManager;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ggh
 * @date 2022/7/18
 */
public enum TextTranslateToolEnum {
    BAIDU_TRANSLATE_PLUGIN(1, "百度翻译插件", PluginManager.baiduTranslatePlugin()),
    YOUDAO_TRANSLATE_PLUGIN(2, "有道翻译插件", PluginManager.youdaoTranslatePlugin()),
    SOUGOU_TRANSLATE_PLUGIN(3, "搜狗翻译插件", PluginManager.sougouTranslatePlugin()),
    JINSHAN_TRANSLATE_PLUGIN(4, "金山词霸翻译插件", PluginManager.jinshanTranslatePlugin()),
    IFLAYREC_TRANSLATE_PLUGIN(5, "讯飞听见翻译插件", PluginManager.iFlyRecTranslatePlugin());
    //需要登陆
//    XUNFEI_TRANSLATE_PLUGIN(4, "科大讯飞翻译插件", new XunFeiTranslatePlugin())

    private int value;

    private String msg;

    private TextTranslatePlugin textTranslatePlugin;

    TextTranslateToolEnum(int value, String msg, TextTranslatePlugin textTranslatePlugin) {
        this.value = value;
        this.msg = msg;
        this.textTranslatePlugin = textTranslatePlugin;
    }

    public static TextTranslateToolEnum parse(int value) {
        for (TextTranslateToolEnum textTranslateToolEnum : values()) {
            if (textTranslateToolEnum.getValue() == value) {
                return textTranslateToolEnum;
            }
        }
        return null;
    }

    public static List<Integer> getValues() {
        TextTranslateToolEnum[] textTranslateToolEnums = values();
        List<Integer> values = new ArrayList<>(textTranslateToolEnums.length);

        for (TextTranslateToolEnum textTranslateToolEnum : textTranslateToolEnums) {
            values.add(textTranslateToolEnum.getValue());
        }
        return values;
    }

    public int getValue() {
        return value;
    }

    public String getMsg() {
        return msg;
    }

    public TextTranslatePlugin getTranslatePlugin() {
        return textTranslatePlugin;
    }
}
